package com.zj.fx.service.rpa;

import cn.hutool.core.util.StrUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zj.fx.common.base.BaseService;
import com.zj.fx.common.support.ConvertUtil;
import com.zj.fx.mapper.rpa.RpaRecordPushMapper;
import com.zj.fx.model.custom.Tablepar;
import com.zj.fx.model.rpa.RpaRecordPush;
import com.zj.fx.model.rpa.RpaRecordPushExample;
import com.zj.fx.util.SnowflakeIdWorker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * PPA同步调用同步接口记录台账 RpaRecordPushService
 *
 * @author SQL_自动生成
 * @Title: RpaRecordPushService.java 
 * @Package com.zj.fx.service 
 * @email ${email}
 * @date 2023-10-27 10:06:01  
 **/
@Service
public class RpaRecordPushService implements BaseService<RpaRecordPush, RpaRecordPushExample> {
    @Autowired
    private RpaRecordPushMapper rpaRecordPushMapper;


    /**
     * 分页查询
     *
     * @param
     * @param
     * @return
     */
    public PageInfo<RpaRecordPush> list(Tablepar tablepar, RpaRecordPush rpaRecordPush) {
        RpaRecordPushExample testExample = new RpaRecordPushExample();
        //搜索
        if (StrUtil.isNotEmpty(tablepar.getSearchText())) {//小窗体
            testExample.createCriteria().andLikeQuery2(tablepar.getSearchText());
        } else {//大搜索
            testExample.createCriteria().andLikeQuery(rpaRecordPush);
        }
        //表格排序
        //if(StrUtil.isNotEmpty(tablepar.getOrderByColumn())) {
        //	testExample.setOrderByClause(StringUtils.toUnderScoreCase(tablepar.getOrderByColumn()) +" "+tablepar.getIsAsc());
        //}else{
        //	testExample.setOrderByClause("id ASC");
        //}
        PageHelper.startPage(tablepar.getPage(), tablepar.getLimit());
        List<RpaRecordPush> list = rpaRecordPushMapper.selectByExample(testExample);
        PageInfo<RpaRecordPush> pageInfo = new PageInfo<RpaRecordPush>(list);
        return pageInfo;
    }

    @Override
    public int deleteByPrimaryKey(String ids) {

        List<String> lista = ConvertUtil.toListStrArray(ids);
        RpaRecordPushExample example = new RpaRecordPushExample();
        example.createCriteria().andIdIn(lista);
        return rpaRecordPushMapper.deleteByExample(example);
    }


    @Override
    public RpaRecordPush selectByPrimaryKey(String id) {

        return rpaRecordPushMapper.selectByPrimaryKey(id);

    }


    @Override
    public int updateByPrimaryKeySelective(RpaRecordPush record) {
        return rpaRecordPushMapper.updateByPrimaryKeySelective(record);
    }


    /**
     * 添加
     */
    @Override
    public int insertSelective(RpaRecordPush record) {

        //添加雪花主键id
        record.setId(SnowflakeIdWorker.getUUID());


        return rpaRecordPushMapper.insertSelective(record);
    }


    @Override
    public int updateByExampleSelective(RpaRecordPush record, RpaRecordPushExample example) {

        return rpaRecordPushMapper.updateByExampleSelective(record, example);
    }


    @Override
    public int updateByExample(RpaRecordPush record, RpaRecordPushExample example) {

        return rpaRecordPushMapper.updateByExample(record, example);
    }

    @Override
    public List<RpaRecordPush> selectByExample(RpaRecordPushExample example) {

        return rpaRecordPushMapper.selectByExample(example);
    }


    @Override
    public long countByExample(RpaRecordPushExample example) {

        return rpaRecordPushMapper.countByExample(example);
    }


    @Override
    public int deleteByExample(RpaRecordPushExample example) {

        return rpaRecordPushMapper.deleteByExample(example);
    }


}
